import {
  IsNumber,
  IsNotEmpty,
  IsOptional,
  Min,
  Max,
  IsArray,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class UpdateWatchProgressDto {
  @ApiProperty({ description: '短剧ID', example: 1 })
  @IsNumber()
  @IsNotEmpty()
  shortsId: number;

  @ApiProperty({ description: '章节ID', example: 2 })
  @IsNumber()
  @IsNotEmpty()
  chapterId: number;

  @ApiProperty({
    description: '观看进度（0-100的百分比）',
    example: 75,
    minimum: 0,
    maximum: 100,
  })
  @IsNumber()
  @Min(0)
  @Max(100)
  progress: number;
}

export class WatchLogResponseDto {
  @ApiProperty({ description: '记录ID' })
  id: number;

  @ApiProperty({ description: '用户ID' })
  userId: number;

  @ApiProperty({ description: '短剧ID' })
  shortsId: number;

  @ApiProperty({ description: '章节ID' })
  chapterId: number;

  @ApiProperty({ description: '观看进度（百分比）' })
  progress: number;

  @ApiProperty({ description: '记录时间' })
  timestamp: string;
}

export class ApiWatchLogResponseDto {
  @ApiProperty({ description: '响应状态码', example: 200 })
  code: number;

  @ApiProperty({ description: '响应消息', example: 'success' })
  message: string;

  @ApiProperty({ description: '响应数据' })
  data: WatchLogResponseDto;

  @ApiProperty({ description: '时间戳' })
  timestamp: number;

  @ApiProperty({ description: '请求ID' })
  requestId: string;
}

export class BatchDeleteWatchLogsDto {
  @ApiProperty({
    description: '要删除的观看记录ID数组',
    example: [1, 2, 3],
    type: [Number],
  })
  @IsArray()
  @IsNumber({}, { each: true })
  watchLogIds: number[];
}

export class BatchDeleteWatchLogsResponseDto {
  @ApiProperty({ description: '删除成功的数量' })
  deletedCount: number;

  @ApiProperty({ description: '删除失败的记录ID列表' })
  failedWatchLogIds: number[];

  @ApiProperty({ description: '操作消息' })
  message: string;
}

export class ApiBatchDeleteWatchLogsResponseDto {
  @ApiProperty({ description: '响应状态码', example: 200 })
  code: number;

  @ApiProperty({ description: '响应消息', example: 'success' })
  message: string;

  @ApiProperty({ description: '响应数据' })
  data: BatchDeleteWatchLogsResponseDto;

  @ApiProperty({ description: '时间戳' })
  timestamp: number;

  @ApiProperty({ description: '请求ID' })
  requestId: string;
}
